{% extends "blog/base.html" %}

{% block main %}

<p>类别:
    {% if article.category.parent_category %}
<a href="{% url 'blog:category_detail' article.category.parent_category.slug %}">{{ article.category.parent_category.name }}</a> /
   {% endif %}
<a href="{% url 'blog:category_detail' article.category.slug %}">{{ article.category }}</a>
</p>
<h3>{{ article.title }}
    {% if article.status == "d" %}
    (草稿)
    {% endif %}
</h3>
 {% if article.status == "p" %}
<p>发布于{{ article.pub_date | date:"Y-m-d" }}      浏览{{ article.views }}次</p>
{% endif %}
{% autoescape off %}{# 注释: 基于安全考虑，django会对字符串进行自动html转义，将html标签直接输出而不是执行，这里加上autoescape off关闭转义 #}
<p>{{ article.body }}</p>
{% endautoescape %}
 <p>
     {% include 'blog/comments.html' %}
 </p>
<p>标签:
    {% for tag in article.tags.all %}
    <a href="{% url 'blog:tag_detail' tag.slug %}">{{ tag.name }}</a>,
    {% endfor %}
</p>
{% if article.author == request.user %}
     {% if article.status == "d" %}
        <a href="{% url 'blog:article_publish' article.id article.slug %}">发布</a> |
    {% endif %}
        <a href="{% url 'blog:article_update' article.id article.slug %}">编辑</a> |
        {# <a href="javascript:if(confirm('确实要删除吗?'))location='{% url 'blog:article_delete' article.id article.slug %}'">删除</a> #}
        <a href="#" onclick="delconfirm()">删除</a>
{% endif %}
<script>
    function delconfirm() {
        if (confirm("确定要删除吗？")){
            //go to your delete path
            window.location.href="{% url 'blog:article_delete' article.id article.slug %}"
        }
        else{
            //don't do anything
        }
    }
</script>
{% endblock %}

